home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades ƒ / Split scroll U-D fade.c < prev    next >
Text File  |  1994-04-15  |  3KB  |  119 lines

  1. /**********************************************************************\
  2.  
  3. File:        Split scroll U-D fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 4
  28. #define theWindowWidth (boundsRect.right-boundsRect.left)
  29. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  30.  
  31. pascal short SplitScrollUDFade(Rect boundsRect, Pattern *thePattern);
  32.  
  33. /* Draw a line from the topleft to the bottomright of the screen and split the
  34.    screen into two regions.  The top region scrolls down and the bottom region
  35.    scrolls up. */
  36.    
  37. pascal short SplitScrollUDFade(Rect boundsRect, Pattern *thePattern)
  38. {
  39.     int            x;
  40.     Rect        topdest, bottomdest;
  41.     Rect        topscrollsource, topscrolldest, bottomscrollsource, bottomscrolldest;
  42.     RgnHandle    toprgn,bottomrgn;
  43.     RgnHandle    temprgn, temp2rgn;
  44.     RgnHandle    topsectrgn, bottomsectrgn;
  45.     int            BoxSize;
  46.     GrafPtr        destGrafPtr;
  47.     
  48.     GetPort(&destGrafPtr);
  49.     
  50.     temprgn=NewRgn();
  51.     temp2rgn=NewRgn();
  52.     topsectrgn=NewRgn();
  53.     bottomsectrgn=NewRgn();
  54.     
  55.     BoxSize=theWindowHeight/25;
  56.     toprgn=NewRgn();
  57.     SetEmptyRgn(toprgn);
  58.     MoveTo(0,0);
  59.     OpenRgn();
  60.         Line(theWindowWidth,0);
  61.         Line(0,theWindowHeight);
  62.         LineTo(0,0);
  63.     CloseRgn(toprgn);
  64.     OffsetRgn(toprgn, boundsRect.left, boundsRect.top);
  65.     
  66.     bottomrgn=NewRgn();
  67.     SetEmptyRgn(bottomrgn);
  68.     MoveTo(0,0);
  69.     OpenRgn();
  70.         Line(0,theWindowHeight);
  71.         Line(theWindowWidth,0);
  72.         LineTo(0,0);
  73.     CloseRgn(bottomrgn);
  74.     OffsetRgn(bottomrgn, boundsRect.left, boundsRect.top);
  75.     
  76.     topscrollsource=boundsRect;
  77.     topscrollsource.bottom-=BoxSize;
  78.     topscrolldest = topscrollsource;
  79.     OffsetRect(&topscrolldest, 0, BoxSize);
  80.     topdest = boundsRect;
  81.     topdest.bottom=topdest.top+BoxSize;
  82.     
  83.     bottomscrollsource=boundsRect;
  84.     bottomscrollsource.top+=BoxSize;
  85.     bottomscrolldest=bottomscrollsource;
  86.     OffsetRect(&bottomscrolldest, 0, -BoxSize);
  87.     bottomdest=boundsRect;
  88.     bottomdest.top=bottomdest.bottom-BoxSize;
  89.     
  90.     RectRgn(temprgn, &topdest);
  91.     SectRgn(toprgn, temprgn, topsectrgn);
  92.     
  93.     RectRgn(temp2rgn, &bottomdest);
  94.     SectRgn(bottomrgn, temp2rgn, bottomsectrgn);
  95.     
  96.     for(x = theWindowHeight; x >= 0; x -= BoxSize)
  97.     {
  98.         StartTiming();
  99.         CopyBits(&(destGrafPtr->portBits), &(destGrafPtr->portBits),
  100.                 &topscrollsource, &topscrolldest, 0, toprgn);        
  101.         CopyBits(&(destGrafPtr->portBits), &(destGrafPtr->portBits),
  102.                 &bottomscrollsource, &bottomscrolldest, 0, bottomrgn);
  103.         
  104.         FillRgn(bottomsectrgn, *thePattern);
  105.         FillRgn(topsectrgn, *thePattern);
  106.         
  107.         TimeCorrection(CorrectTime);
  108.     }
  109.     
  110.     DisposeRgn(toprgn);
  111.     DisposeRgn(bottomrgn);
  112.     DisposeRgn(temprgn);
  113.     DisposeRgn(temp2rgn);
  114.     DisposeRgn(topsectrgn);
  115.     DisposeRgn(bottomsectrgn);
  116.     
  117.     return 0;
  118. }
  119.